/****
 * 全局插件
 ****/
// 全局过滤器
import filters from '@/utils/filters'
// 全局组件
import components from '@/components'

export default {
  install (Vue) {
    // 注册全局过滤器
    for (const key of Object.keys(filters)) {
      Vue.filter(key, filters[key])
    }

    // 注册全局组件
    for (const key of Object.keys(components)) {
      Vue.component(components[key].name, components[key])
    }
    Vue.prototype.$filters = filters
    Vue.config.productionTip = false

    if (process.env.NODE_ENV === 'development') {
      Vue.prototype.log = function log () {
        for (let i = 0; i < arguments.length; i += 1) {
          if (typeof arguments[i] === 'object') {
            try {
              arguments[i] = JSON.parse(JSON.stringify(arguments[i]))
            } catch (e) {
              // console.error(e)
            }
          }
        }
        // console.log(...arguments)
      }
    }
  }
}
